<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>1class样式的绑定</title>
        <style>
			.basic{
				width: 400px;
				height: 100px;
				border: 1px solid black;
			}
			
			/* 三种心情，三选一 */
			.happy{
				border: 4px solid rgb(128, 33, 33);;
				background-color: rgba(124, 131, 228, 0.644);
				background: linear-gradient(30deg,rgb(196, 241, 137),rgb(192, 237, 255),rgb(0, 140, 255),rgb(191, 93, 230));
			}
			.sad{
				border: 4px dashed black;
				background-color: gray;
			}
			.normal{
				border: 4px solid deepskyblue;
				background-color: skyblue;
			}
			
			/* 三个样式，随意选择，可以同时存在 */
			.atguigu1{
				background-color: rgb(202, 245, 117);
			}
			.atguigu2{
				font-size: 30px;
				text-shadow:2px 2px 10px rgba(255, 0, 0, 0.548);
			}
			.atguigu3{
				border-radius: 20px;
			}
		</style>
        <!-- 引入Vue -->
        <script type="text/javascript" src="../js/vue.js"></script>
    </head>
    <body>
        <!-- 准备好一个容器-->
        <div id="demo">
            <div class="basic" :class='str'>class样式的绑定-字符串</div>
            <br>
            <button style="display: block;" @click='changeMood'>切换心情</button>
        <br>
        <hr>
        <br>

            <div class="basic" :class='obj'>class样式的绑定-对象</div>
            <br>
            <button @click='change1'>atguigu1</button>
            <button @click='change2'>atguigu2</button>
            <button @click='change3'>atguigu3</button>

            <hr>
            <div class="basic" :class='arr'>class样式的绑定-对象</div>
            <button @click='changeA' >atguigu1</button>
            <button @click='changeB'>atguigu2</button>
            <button @click='changeC'>atguigu3</button>
        </div>
    </body>

    <script type="text/javascript">
        //阻止 vue 在启动时生成生产提示。
        Vue.config.productionTip = false
        new Vue({
			el:'#demo',
            data:{
                str:'happy',
                obj:{
                    atguigu1:true,
                    atguigu2:true,
                    atguigu3:true
                },
                arr:[]
            },
            methods: {
                changeMood(){
                    let arr=['happy','sad','normal']
                    this.str=arr[Math.floor(Math.random()*3)]
                },
                change1(){
                    this.obj.atguigu1=!this.obj.atguigu1
                },
                change2(){
                    this.obj.atguigu2=!this.obj.atguigu2
                },
                change3(){
                    this.obj.atguigu3=!this.obj.atguigu3
                },
                changeA(e){
                    console.log(e.target.innerHTML)
                   this.arr.push(e.target.innerHTML)
                },
                changeB(e){
                    this.arr.push(e.target.innerHTML)
                },
                changeC(e){
                    this.arr.push(e.target.innerHTML)
                },
                
            }
		})
    </script>
</html>